import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/
export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true }
]

export default new Router({
  // mode: 'history', // 后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

export const asyncRouterMap = [
  {
    path: '/home',
    component: Layout,
    redirect: '/home/homeData',
    meta: { title: '首页', icon: 'gerenxinxi' },
    name: 'home',
    children: [
      {
        path: 'homeData',
        name: 'homeData',
        component: () => import('@/views/home/index'),
        meta: { title: '商家首页', icon: 'setting' }
      }
    ]
  },
  // {
  //   path: '/scoket',
  //   component: Layout,
  //   redirect: '/scoket/scoketData',
  //   meta: { title: '首页', icon: 'gerenxinxi' },
  //   name: 'scoket',
  //   children: [
  //     {
  //       path: 'scoketData',
  //       name: 'scoketData',
  //       component: () => import('@/views/layout/webSoket'),
  //       meta: { title: 'web', icon: 'setting' }
  //     }
  //   ]
  // },
  // 新
  {
    path: '/order',
    component: Layout,
    redirect: '/order/orderData',
    meta: { title: '订单管理', icon: 'gerenxinxi' },
    name: 'order',
    children: [
      {
        path: 'orderData',
        name: 'orderData',
        component: () => import('@/views/merchant/order/index'),
        meta: { title: '订单', icon: 'gerenxinxi' }
      }
    ]
  },
  { // 新
    path: '/goods',
    component: Layout,
    redirect: '/goods/goodsData',
    name: 'goods',
    children: [
      {
        path: 'goodsData',
        name: 'goodsData',
        component: () => import('@/views/merchant/goods/index'),
        meta: { title: '商品管理', icon: 'setting' }
      },
      {
        path: 'goodsData/:id',
        name: 'goodsDetail',
        hidden: true,
        component: () => import('@/views/merchant/goods/detail'),
        meta: { title: '商品详情', icon: 'setting' }
      }
    ]
  },
  { // 新
    path: '/customer',
    component: Layout,
    redirect: '/customer/customerData',
    name: 'customer',
    children: [
      {
        path: 'customerData',
        name: 'customerData',
        component: () => import('@/views/merchant/customer/index'),
        meta: { title: '顾客评价', icon: 'setting' }
      },
      {
        path: 'customerData/1',
        name: 'customerDetail',
        hidden: true,
        component: () => import('@/views/merchant/customer/detail'),
        meta: { title: '评价详情', icon: 'setting' }
      }
    ]
  },

  { // 新
    path: '/money',
    component: Layout,
    redirect: '/money/moneyData',
    meta: { title: '财务管理', icon: 'shanghu' },
    name: 'money',
    children: [
      {
        path: 'moneyData',
        name: 'moneyData',
        component: () => import('@/views/merchant/money/index'),
        meta: { title: '对账首页', icon: 'setting' }
      },
      {
        path: 'bill',
        name: 'bill',
        component: () => import('@/views/merchant/money/bill'),
        meta: { title: '账单对账', icon: 'setting' }
      },
      {
        path: 'account',
        name: 'account',
        component: () => import('@/views/merchant/money/account'),
        meta: { title: '账户管理', icon: 'setting' }
      }
    ]
  },
  { // 新
    path: '/activity',
    component: Layout,
    redirect: '/activity/activityData',
    meta: { title: '营销活动', icon: 'shanghu' },
    name: 'activity',
    children: [
      {
        path: 'activityData',
        name: 'activityData',
        component: () => import('@/views/merchant/activity/index'),
        meta: { title: '店铺活动', icon: 'setting' }
      }
      // {
      //   path: 'traffic',
      //   name: 'traffic',
      //   component: () => import('@/views/merchant/activity/traffic'),
      //   meta: { title: '流量活动', icon: 'setting' }
      // }
    ]
  },

  {
    path: '/shop',
    component: Layout,
    redirect: '/shop/decorate',
    meta: { title: '店铺设置', icon: 'shanghu' },
    name: 'shop',
    children: [
      // {
      //   path: 'system',
      //   name: 'shopSystem',
      //   component: () => import('@/views/merchant/shop/system/index'),
      //   meta: { title: '系统设置', icon: 'picture' }
      // },
      {
        path: 'stores',
        name: 'stores',
        component: () => import('@/views/merchant/shop/stores/index'),
        meta: { title: '门店管理', icon: 'picture' }
      },
      {
        path: 'message',
        name: 'shopMessage',
        component: () => import('@/views/merchant/shop/message/index'),
        meta: { title: '消息中心', icon: 'picture' }
      }
      // {
      //   path: 'decorate',
      //   name: 'decorate',
      //   component: () => import('@/views/merchant/shop/decorate/index'),
      //   meta: { title: '门店装修', icon: 'picture' }
      // }
    ]
  },
  {
    path: '/person',
    component: Layout,
    redirect: '/person/basicInformation',
    meta: { title: '个人设置', icon: 'gerenxinxi' },
    name: 'person',
    children: [
      {
        path: 'basicInformation',
        name: 'basicInformation',
        component: () => import('@/views/person/basic/index'),
        meta: { title: '修改账号信息', icon: 'setting' }
      }
    ]
  },

  { path: '*', redirect: '/404', hidden: true }
]
